//
//  WXPCreditReportDetailVC.m
//  信用报告
//
//  Created by wxp on 2025/3/11.
//

#import "WXPCreditReportDetailVC.h"
#import <WebKit/WebKit.h>

@interface WXPCreditReportDetailVC ()

@property (nonatomic, strong) WXPNavView * navView;
@property (nonatomic, strong) WKWebView * webView;

@end

@implementation WXPCreditReportDetailVC

#pragma mark - lazy
- (WXPNavView *)navView{
    if (_navView == nil) {
        _navView = [WXPNavView new];
//        _navView.btnService.hidden = true;
        [_navView resetViewWithTitle:@"Mi credito"];
        _navView.leftTop = XY(0, 0);
    }
    return  _navView;
}
- (WKWebView *)webView{
    if (_webView == nil) {
        WKWebViewConfiguration *webViewConfiguration = [[WKWebViewConfiguration alloc] init];
        WKPreferences *preferences = [[WKPreferences alloc] init];
        preferences.javaScriptEnabled = YES;
        webViewConfiguration.preferences = preferences;
        WKWebsiteDataStore *dataStore = [WKWebsiteDataStore defaultDataStore];
        webViewConfiguration.websiteDataStore = dataStore;
        _webView = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, 0, 0) configuration:webViewConfiguration];
        _webView.frame = CGRectMake(0, [GlobalMethod getNavgationBarHeight], SCREEN_WIDTH, SCREEN_HEIGHT-[GlobalMethod getNavgationBarHeight]);
        _webView.scrollView.bounces = NO;
        self.edgesForExtendedLayout = UIRectEdgeNone;
        NSString * html = @"";
#if DEBUG
        html = [NSString stringWithFormat:@"%@/app-loanmarket-h5-creditreport/#/%@?phone=%@&userId=%@", DOMAIN_NAME, self.type == ENUM_REPORT_FICO ? @"fico" : @"cloudun", [GlobalData sharedInstance].Global_ModelUser.phone, [GlobalData sharedInstance].Global_UserCode];
#else
        html = [NSString stringWithFormat:@"%@/credit-report/index.html#/%@?phone=%@&userId=%@", DOMAIN_NAME, self.type == ENUM_REPORT_FICO ? @"fico" : @"cloudun", [GlobalData sharedInstance].Global_ModelUser.phone, [GlobalData sharedInstance].Global_UserCode];
#endif
        [_webView loadRequest:[[NSURLRequest alloc] initWithURL:[NSURL URLWithString:html]]];
    }
    return  _webView;
}

#pragma mark - viewDidLoad
- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    // 打点
    [GlobalMethod hitPointWithPageName:KEY_CreditReport action:KEY_Enter extInfo:nil];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.navView];
    self.tableHeaderTopBg.backgroundColor = [UIColor clearColor];
    self.tableView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.webView];
}

@end
